package com.zyh.service.impl;

import com.zyh.entity.Book;
import com.zyh.mapper.BookMapper;
import com.zyh.service.BookService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;
@Service
public class BookServiceImpl implements BookService {
    @Autowired
    private BookMapper bookMapper;

    @Override
    public void insert(Book book) {
        bookMapper.insert(book);
    }

    @Override
    public void deleteByBookId(Integer bookId) {
        bookMapper.deleteByBookId(bookId);
    }

    @Override
    public void deletesByTypeId(Integer typeId) {
        bookMapper.deletesByTypeId(typeId);
    }

    @Override
    public void deletesByBookId(int[] ids) {
        bookMapper.deletesByBookId(ids);
    }

    @Override
    public void updateByBookId(Book book) {
        bookMapper.updateByBookId(book);
    }

    @Override
    public Book selectByBookId(Integer bookId) {
        return bookMapper.selectByBookId(bookId);
    }

    @Override
    public int selectCount() {
        return bookMapper.selectCount();
    }

    @Override
    public List<Book> selectByTypeId(Integer typeId) {
        return bookMapper.selectByTypeId(typeId);
    }

    @Override
    public List<Book> selectBooks(Integer start,Integer pageSize,
                                  @Param("nameSearch") String nameSearch,
                                  @Param("priceSearch") Double priceSearch,
                                  @Param("typeSearch") String typeSearch) {
        return bookMapper.selectBooks(start, pageSize,nameSearch,priceSearch,typeSearch);
    }
}
